package org.wuliu.Controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.wuliu.dao.*;
import org.wuliu.pojo.*;
import org.wuliu.utils.*;

import java.util.List;

@Controller
@RequestMapping("/qvyv")
@CrossOrigin(value = "*")
public class QvyvController {
    @Autowired
    private QuyvDao quyvDao;
    @RequestMapping("/show")
    @ResponseBody
    public ResponseResult getAll(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit,Quyv quyv){
        Page<Quyv> pag= PageHelper.startPage(page,limit);
        List<Quyv> list=quyvDao.getList(quyv);
        return new ResponseResult(pag.getTotal(),list);
    }
    @RequestMapping("/add")
    @ResponseBody
    public ResponseResult getadd(Quyv quyv){
        quyvDao.add(quyv);
        return ResponseResult.createSuccessResUle();
    }
    @RequestMapping("/update")
    @ResponseBody
    public ResponseResult update(Quyv quyv){
        quyvDao.update(quyv);
        return ResponseResult.createSuccessResUle();
    }
}
